<template>
  <div class="box">
    <div class="upload-box">
      <div class="txt" style="margin-bottom:10px">上传转账凭证</div>
      <el-upload :action="fun.getRealUrl('upload.uploadPic')" limit="1" list-type="picture-card" :on-success="uploadSuccess1"
        :on-remove="handleRemove1">
        <i class="el-icon-plus"></i>
      </el-upload>
      <van-button   style="width:100%;margin-top:20px" type="danger"  @click="handlePartnerClick">确认 </van-button>
    </div>
    <div class="illustrate">{{illustrate}}</div>
  </div>
</template>
<script>
import { Toast } from 'vant';
export default {
  data() {
    return {
      imgList1: [],
      fileList1:[],
      illustrate:''
    };
  },
  created() {
    this.getIllustrate();
  },
  computed: {

  },
  methods: {
    uploadSuccess1(response, file, fileList) {
      console.log(fileList);
      this.fileList1 = fileList;
    },
    handleRemove1(file, fileList) {
      this.fileList1 = fileList;
    },
    handlePartnerClick() {
      this.imgList1 = [];
      this.fileList1.forEach(item => {
        this.imgList1.push(item.response.data.img_url);
      });
      if (this.imgList1.length === 0) {
        Toast("请上传转账凭证");
        return;
      }
      let json = {
        user_uid: localStorage.getItem('uid'),
        goods_option_id: 0,
        goods_id: this.$route.query.id,
        pay_proof: this.imgList1[0]
      };
      $http.post("plugin.goods-agent.frontend.agent.putIn", json, " ").then(
        res => {
          if (res.result == 1) {
            this.$dialog.alert({ message: '已提交申请，等待审核！' });
          }

        },
        function (res) {
          console.log(res);
        }
      );
    },
    getIllustrate() {
      $http.post("plugin.goods-agent.frontend.agent.get-pay-proof-blurb", {}, " ").then(
        res => {
          if(res.result == 1){
            this.illustrate = res.data;
          }
          
        },
        function(res) {
          console.log(res);
        }
      );
    },
  }
};    
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
.upload-box {
  text-align: left;
  padding:15px;
  background-color: #fff;
}
.illustrate{
  color:#666;
  text-align: left;
  margin-top: 15px;
}
</style>
